function handleMsg(e) {
  document.getElementById('appFrame').height = e.data;
  $(document).trigger('scroll');
}

$(function() {
  $(window).scrollTop(0);
  if ($("js-appType").val() == "live_index") {
    changeMenu('datahover');
  } else {
    changeMenu('app');
  }


  $(document).scroll(function() {
    var availHeight;
    var centerY;
    var scrollTop = $(document).scrollTop();
    var windowHeight = $(window).height();
    var documentHeight = $(document).height();
    var navbarHeight = $(".header_top").outerHeight(true);
    var footerHeight = $(".footer").outerHeight(true);
    // 计算嵌入页面的可见高度
    if (documentHeight < navbarHeight + windowHeight + footerHeight) { //导航、页脚同时可见时
      availHeight = 2 * documentHeight - navbarHeight - windowHeight - footerHeight;
    } else if (scrollTop < navbarHeight) { //导航可见时
      availHeight = windowHeight - navbarHeight + scrollTop;
    } else if (scrollTop + windowHeight > documentHeight - footerHeight) { //页脚可见时
      availHeight = documentHeight - footerHeight - scrollTop;
    } else {
      availHeight = windowHeight;
    }
    // 计算可见页面的垂直居中点
    if (scrollTop < navbarHeight) {
      centerY = availHeight / 2;
    } else {
      centerY = scrollTop - navbarHeight + availHeight / 2;
    }
    document.getElementById('appFrame').contentWindow.postMessage(availHeight + "," + centerY, "*");
  });
